﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Emerson.Storage.Agent.Core;

namespace Simulator
{
    public partial class SimulatorForm : Form
    {
        SimulatorService service;
        public SimulatorForm()
        {
            InitializeComponent();

            try
            {
                SimulatorService.formReference = this;
                service = new SimulatorService();
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot initiate service, make sure only one instance is running");
                this.Enabled = false;
            }
        }

        public BatteryInfo GetBatteryInfo()
        {
            BatteryInfo bi = new BatteryInfo();
            bi.BatteryType = "Simulator";
            bi.Chemistry = textBoxChemistry.Text;
            bi.PercentRemaining = double.Parse(textBoxPercentRemaining.Text);
            if (checkBoxChargeToggler.Checked)
                bi.BatteryChargingState = BatteryChargingState.Discharging;
            else
                bi.BatteryChargingState = BatteryChargingState.Charging;
            bi.Temperature = double.Parse(textBoxTemperature.Text);
            return bi;
        }

        private void checkBoxCharge_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxChargeToggler.Checked)
            {
                checkBoxChargeToggler.Text = "Discharging";
                checkBoxChargeToggler.BackColor = Color.Azure;
            }
            else
            {
                checkBoxChargeToggler.Text = "Charging";
                checkBoxChargeToggler.BackColor = Color.Lime;
            }
        }

        private void checkBoxChargeToggler_Click(object sender, EventArgs e)
        {

        }
    }
}
